﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Expo.Training.Entity;

public partial class Masterpage_CommonPage : MasterpageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        BindModule();
        SetHash();
    }

    private void SetHash()
    {
        AddEndScript("SetHash", "jQuery(function(){setHash();});");
    }

    private void BindModule()
    {
        Module_Info_New gEntity = new Module_Info_New();
        gEntity.ModuleArea = this.CurrentEnvironment.Area;
        gEntity.CustomCondition = "CustomerID in ('00000000-0000-0000-0000-000000000000','" + this.Member.CustomerID.ToString() + "')";
        PPTech.ESP.DataProvider.DataBox moduleList = gEntity.Query();
        if (moduleList.Count > 0)
        {
            Module_Info_New objModule = new Module_Info_New();
            Module_Info_New objParent = new Module_Info_New();
            int sectionID = 0;
            bool needBind = false;
            for (int i = 0; i < moduleList.Count; i++)
            {
                objModule = (Module_Info_New)moduleList[i];
                objParent.ModuleID = objModule.ParentID;
                if (objParent.Exist())
                {
                    needBind = true;
                    sectionID = objParent.SectionID;
                }
                if (objModule.CustomerID != Guid.Empty.ToString())
                {
                    break;
                }
            }
            if (needBind == true)
            {
                this.CurrentEnvironment.ModuleID = objModule.ModuleID;
                AddEndScript("BindModule", "function showPageEvent(){triggerMenu(\"" + objParent.SectionID + "\", \"" + objModule.ParentID + "\", \"" + objModule.ModuleID + "\");} jQuery(function(){showPageEvent();});");
            }
        }
    }
}
